
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
request.setAttribute("decorator", "none");
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%>

<!-- Nestable List -->
<script src="js/plugins/nestable/jquery.nestable.js"></script>

<%-- 导入面包屑 --%>
<jsp:include page="../common/nav.jsp"></jsp:include>

<div class="wrapper wrapper-content animated fadeInRight">
	
	<div class="row">
		<div class="col-lg-12">
			<div class="ibox ">
		        <div class="ibox-title">
		            <h4>多级物料清单</h4>
		            <div class="ibox-tools">
		            </div>
		        </div>
				<div class="ibox-content border-bottom" style="padding-bottom: 0px;">
					<div class="dd" id="nestable">
					</div>
				</div>
			</div>
		</div>
		
	</div>
</div>

<script>
	$(document).ready(function() {
		//获取bom树
		getBomTreeHtml("${param.bomHeadCode}");
	
	    $('#nestable').nestable({
	    });
	    
	    $("#nestable").on("click", ".dd-handle", function(){
	    	if($(this).parent("li").find("button[data-action='collapse']").css("display")=="none"){
	    		$(this).parent("li").find("button[data-action='expand']").click();
	    		
	    	}else{
	    		$(this).parent("li").find("button[data-action='collapse']").click();
	    	}
	    });
	});
	
	function getBomTreeHtml(bomHeadCode){
		$.ajax({
			type: "post",
			url: "web/prodBomHead/getBomTreeHtml",
			data: {"bomHeadCode": bomHeadCode},
			async: false,
			dataType: "html",
			cache: false,
			success: function(data){
				$("#nestable").html(data);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){
				redragonJS.alert(textStatus);
			}
		});
	}
</script>       